import moment from 'moment';
import { tableListDataSource } from './deviceManage';
// mock data
const visitData = [];
const beginDay = new Date().getTime();
const fakeY = [7, 5, 4, 2, 4, 7, 5, 6, 5, 9, 6, 3, 1, 5, 3, 6, 5];

for (let i = 0; i < fakeY.length; i += 1) {
  visitData.push({
    x: moment(new Date(beginDay + 1000 * 60 * 60 * 24 * i)).format('YYYY-MM-DD'),
    y: fakeY[i],
  });
}

let visitData2 = [];
const fakeY2 = [1, 6, 4, 8, 3, 7, 2];

// for (let i = 0; i < fakeY2.length; i += 1) {
//   visitData2.push({
//     x: moment(new Date(beginDay + 1000 * 60 * 60 * 24 * i)).format('YYYY-MM-DD'),
//     y: fakeY2[i],
//   });
// }
visitData2 = fakeY2;

const salesData = [];

for (let i = 0; i < 12; i += 1) {
  salesData.push({
    x: `${i + 1}月`,
    y: Math.floor(Math.random() * 1000) + 200,
  });
}

const searchData = [];

for (let i = 0; i < 50; i += 1) {
  searchData.push({
    index: i + 1,
    keyword: `${tableListDataSource[i]?.deviceName}`,
    count: Math.floor(Math.random() * 1000),
    range: Math.floor(Math.random() * 100),
    status: Math.floor((Math.random() * 10) % 2),
  });
}

const salesTypeData = [
  {
    x: 'GE',
    y: 4544,
  },
  {
    x: 'MR',
    y: 3321,
  },
  {
    x: 'AW',
    y: 3113,
  },
  {
    x: 'PETCT',
    y: 2341,
  },
  {
    x: 'NM',
    y: 1493,
  },
  {
    x: '其他',
    y: 1231,
  },
];
const salesTypeDataOnline = [
  {
    x: '家用电器',
    y: 244,
  },
  {
    x: '食用酒水',
    y: 321,
  },
  {
    x: '个护健康',
    y: 311,
  },
  {
    x: '服饰箱包',
    y: 41,
  },
  {
    x: '母婴产品',
    y: 121,
  },
  {
    x: '其他',
    y: 111,
  },
];
const salesTypeDataOffline = [
  {
    x: '家用电器',
    y: 99,
  },
  {
    x: '食用酒水',
    y: 188,
  },
  {
    x: '个护健康',
    y: 344,
  },
  {
    x: '服饰箱包',
    y: 255,
  },
  {
    x: '其他',
    y: 65,
  },
];
const offlineData = [];
const hospitalNames = [
  '成都市第一人民医院',
  '四川大学华西医院',
  '四川省人民医院',
  '四川肿瘤医院',
  '四川大学华西口腔医院',
  '中国医学科学院北京协和医院',
  '中国人民解放军总医院',
  '复旦大学附属中山医院',
  '北京大学人民医院',
  '浙江大学医学院附属第一医院',
];
for (let i = 0; i < 10; i += 1) {
  offlineData.push({
    name: `${hospitalNames[i]}`,
    cvr: Math.ceil(Math.random() * 9) / 10,
  });
}

const offlineChartData = [];

for (let i = 0; i < 20; i += 1) {
  const date = moment(new Date().getTime() + 1000 * 60 * 30 * i).format('HH:mm');
  offlineChartData.push({
    date,
    type: '系统流量',
    value: Math.floor(Math.random() * 100) + 10,
  });
  offlineChartData.push({
    date,
    type: '访问次数',
    value: Math.floor(Math.random() * 100) + 10,
  });
}

const radarOriginData = [
  {
    name: '个人',
    ref: 10,
    koubei: 8,
    output: 4,
    contribute: 5,
    hot: 7,
  },
  {
    name: '团队',
    ref: 3,
    koubei: 9,
    output: 6,
    contribute: 3,
    hot: 1,
  },
  {
    name: '部门',
    ref: 4,
    koubei: 1,
    output: 6,
    contribute: 5,
    hot: 7,
  },
];
const radarData = [];
const radarTitleMap = {
  ref: '引用',
  koubei: '口碑',
  output: '产量',
  contribute: '贡献',
  hot: '热度',
};
radarOriginData.forEach((item) => {
  Object.keys(item).forEach((key) => {
    if (key !== 'name') {
      radarData.push({
        name: item.name,
        label: radarTitleMap[key],
        value: item[key],
      });
    }
  });
});

const lineChartData = [
  {
    Date: '2015-04',
    scales: 1998,
  },
  {
    Date: '2015-05',
    scales: 1850,
  },
  {
    Date: '2015-06',
    scales: 1720,
  },
  {
    Date: '2015-07',
    scales: 1818,
  },
  {
    Date: '2015-08',
    scales: 1920,
  },
  {
    Date: '2015-09',
    scales: 1802,
  },
  {
    Date: '2015-10',
    scales: 1945,
  },
  {
    Date: '2015-11',
    scales: 1856,
  },
  {
    Date: '2015-12',
    scales: 2107,
  },
  {
    Date: '2016-01',
    scales: 2140,
  },
  {
    Date: '2016-02',
    scales: 2311,
  },
  {
    Date: '2016-03',
    scales: 1972,
  },
  {
    Date: '2016-04',
    scales: 1760,
  },
  {
    Date: '2016-05',
    scales: 1824,
  },
  {
    Date: '2016-06',
    scales: 1801,
  },
  {
    Date: '2016-07',
    scales: 2001,
  },
  {
    Date: '2016-08',
    scales: 1640,
  },
  {
    Date: '2016-09',
    scales: 1502,
  },
  {
    Date: '2016-10',
    scales: 1621,
  },
  {
    Date: '2016-11',
    scales: 1480,
  },
  {
    Date: '2016-12',
    scales: 1549,
  },
  {
    Date: '2017-01',
    scales: 1390,
  },
  {
    Date: '2017-02',
    scales: 1325,
  },
  {
    Date: '2017-03',
    scales: 1250,
  },
  {
    Date: '2017-04',
    scales: 1394,
  },
  {
    Date: '2017-05',
    scales: 1406,
  },
  {
    Date: '2017-06',
    scales: 1578,
  },
  {
    Date: '2017-07',
    scales: 1465,
  },
  {
    Date: '2017-08',
    scales: 1689,
  },
  {
    Date: '2017-09',
    scales: 1755,
  },
  {
    Date: '2017-10',
    scales: 1495,
  },
  {
    Date: '2017-11',
    scales: 1508,
  },
  {
    Date: '2017-12',
    scales: 1433,
  },
  {
    Date: '2018-01',
    scales: 1344,
  },
  {
    Date: '2018-02',
    scales: 1201,
  },
  {
    Date: '2018-03',
    scales: 1065,
  },
  {
    Date: '2018-04',
    scales: 1255,
  },
  {
    Date: '2018-05',
    scales: 1429,
  },
  {
    Date: '2018-06',
    scales: 1398,
  },
  {
    Date: '2018-07',
    scales: 1678,
  },
  {
    Date: '2018-08',
    scales: 1524,
  },
  {
    Date: '2018-09',
    scales: 1688,
  },
  {
    Date: '2018-10',
    scales: 1500,
  },
  {
    Date: '2018-11',
    scales: 1670,
  },
  {
    Date: '2018-12',
    scales: 1734,
  },
  {
    Date: '2019-01',
    scales: 1699,
  },
  {
    Date: '2019-02',
    scales: 1508,
  },
  {
    Date: '2019-03',
    scales: 1680,
  },
  {
    Date: '2019-04',
    scales: 1750,
  },
  {
    Date: '2019-05',
    scales: 1602,
  },
  {
    Date: '2019-06',
    scales: 1834,
  },
  {
    Date: '2019-07',
    scales: 1722,
  },
  {
    Date: '2019-08',
    scales: 1430,
  },
  {
    Date: '2019-09',
    scales: 1280,
  },
  {
    Date: '2019-10',
    scales: 1367,
  },
  {
    Date: '2019-11',
    scales: 1155,
  },
  {
    Date: '2019-12',
    scales: 1289,
  },
  {
    Date: '2020-01',
    scales: 1104,
  },
  {
    Date: '2020-02',
    scales: 1246,
  },
  {
    Date: '2020-03',
    scales: 1098,
  },
  {
    Date: '2020-04',
    scales: 1189,
  },
  {
    Date: '2020-05',
    scales: 1276,
  },
  {
    Date: '2020-06',
    scales: 1033,
  },
  {
    Date: '2020-07',
    scales: 1956,
  },
  {
    Date: '2020-08',
    scales: 1845,
  },
  {
    Date: '2020-09',
    scales: 1089,
  },
  {
    Date: '2020-10',
    scales: 1944,
  },
  {
    Date: '2020-11',
    scales: 1343,
  },
  {
    Date: '2020-12',
    scales: 1893,
  },
  {
    Date: '2021-01',
    scales: 1840,
  },
  {
    Date: '2021-02',
    scales: 1934,
  },
  {
    Date: '2021-03',
    scales: 1810,
  },
  {
    Date: '2021-04',
    scales: 1782,
  },
  {
    Date: '2021-05',
    scales: 1089,
  },
  {
    Date: '2021-06',
    scales: 1745,
  },
  {
    Date: '2021-07',
    scales: 1680,
  },
  {
    Date: '2021-08',
    scales: 1802,
  },
  {
    Date: '2021-09',
    scales: 1697,
  },
  {
    Date: '2021-10',
    scales: 1583,
  },
  {
    Date: '2021-11',
    scales: 1456,
  },
  {
    Date: '2021-12',
    scales: 1524,
  },
  {
    Date: '2022-01',
    scales: 1398,
  },
  {
    Date: '2022-02',
    scales: 2178,
  },
  {
    Date: '2022-03',
    scales: 1195,
  },
  {
    Date: '2022-04',
    scales: 1145,
  },
  {
    Date: '2022-05',
    scales: 1207,
  },
];
const getFakeChartData = {
  visitData,
  visitData2,
  salesData,
  searchData,
  offlineData,
  offlineChartData,
  salesTypeData,
  salesTypeDataOnline,
  salesTypeDataOffline,
  radarData,
  lineChartData,
};

const fakeChartData = (_, res) => {
  return res.json({
    data: getFakeChartData,
  });
};

export default {
  'GET  /api/getDataVisualization': fakeChartData,
};
